const app = new Vue({
  el: '#app',
  data: {
    swiperList:[],
    groupList: [],
    goodsList:[]
  },
  created() {
    this.getData()
  },
  mounted() {
    // 确保在数据加载完成后初始化Swiper
    this.getData().then(() => {
      const mySwiper = new Swiper(".swiper", {
        speed: 1000,
        loop: true,
        autoplay: {
          disableOnInteraction: false,
          delay: 2000,
        },
        pagination: {
          el: ".swiper-pagination",
        },
        centeredSlides: true,
        observer: true, // 修改swiper自己或子元素时，自动初始化swiper
        observeParents: true, // 修改swiper的父元素时，自动初始化swiper
      });
    });
  },
  methods: {
    async getData() {
      const res = await axios.get('http://smart-shop.itheima.net/index.php?s=/api/page/detail')
      console.log(res);
      this.groupList = res.data.data.pageData.items[3].data
      this.swiperList = res.data.data.pageData.items[1].data
      this.goodsList = res.data.data.pageData.items[6].data
    }
  }
})